import type { AddressParams } from "@/types/address"
import type { AddressItem } from "@/types/global"
import { http } from "@/utils/http"

export const useAddressApi = () => {
    return {
        addAddress: (data: AddressParams) => {
            return http<{ id: number }>({
                method: "POST",
                url: "/member/address",
                data
            })
        },
        getAddress: () => {
            return http<AddressItem[]>({
                method: "GET",
                url: "/member/address"
            })
        },
        getAddressById: (id: string) => {
            return http<AddressItem[]>({
                method: "GET",
                url: `/member/address/${id}`
            })
        },
        updateAddress: (id: string, data: AddressParams) => {
            return http<{ id: number }>({
                method: "PUT",
                url: `/member/address/${id}`,
                data
            })
        },
        deleteAddress: (id: string) => {
            return http<{ id: string }>({
                method: "DELETE",
                url: `/member/address/${id}`
            })
        }
    }
}